import Person from "./person"
import Class from "./class"
class Teacher extends Person{
    constructor(id,name,age,klasses){
        super(id,name,age);
        this.klasses=klasses;
    }
    introduce(){
        let introduce;
        if(this.klasses!=undefined){
            introduce=super.introduce()+` I am a Teacher. I teach Class`;
            for(let i=0;i<this.klasses.length;i++){
                introduce+=` ${this.klasses[i].number}`;
                if(i!=this.klasses.length-1){
                    introduce+=",";
                }
                else{
                    introduce+=".";
                }
            }
        }
        else{
            introduce=super.introduce()+` I am a Teacher. I teach No Class.`;
        }
        return introduce;
    }
    introduceWith(studentJerry){
        let introduceWith;
        if(this.klass==studentJerry.klass){
            introduceWith=super.introduce()+` I am a Teacher. I teach Jerry.`
        }
        else{
            introduceWith=super.introduce()+` I am a Teacher. I don't teach Jerry.`
        }
        return introduceWith;
    }
    isTeaching(student){
        if(this.klasses.indexOf(student.klass)==-1){
            return false;
        }
        else{
            return true;
        }
    }
}
module.exports = Teacher;

